#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n), pre(n + 1);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        pre[i + 1] = pre[i] + a[i];
        if(i) a[i] = max(a[i], a[i - 1]);
    } 
    for(int i = 0; i < q; i++){
        ll k;
        cin >> k;
        int p = upper_bound(a.begin(), a.end(), k) - a.begin() - 1;
        if(p == -1) {
            cout << "0 ";
        }else{
            cout << pre[p + 1] << ' ';
        }
    }
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}